package com.demo.reduction;

import com.demo.common.Dish;
import com.demo.common.DishUtil;

import java.util.IntSummaryStatistics;
import java.util.List;

import static java.util.stream.Collectors.averagingInt;
import static java.util.stream.Collectors.summarizingInt;

public class TestAveragingInt {
    public static void main(String[] args) {
        List<Dish> menu = DishUtil.getDishes();
        double avgCalories = menu.stream().collect(averagingInt(Dish::getCalories));
        System.out.println(avgCalories);

        IntSummaryStatistics meniStatistics = menu.stream().collect(summarizingInt(Dish::getCalories));
        System.out.println(meniStatistics.getAverage());
    }
}
